package com.easy.service.impl;

import com.easy.zhu.LogMethod;
import com.easy.bean.ManagerBean;
import com.easy.mapper.ManagerBeanDao;
import com.easy.service.ManagerBeanService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class ManagerServiceImpl implements ManagerBeanService {

    @Autowired
    ManagerBeanDao managerBeanDao;
    @Override
    @LogMethod(serviceName = "用户添加处理")
    public ManagerBean add(ManagerBean managerBean) {
        managerBeanDao.add(managerBean);
        ManagerBean result=managerBeanDao.one(managerBean.getId());
        return result;
    }

    @Override
    @LogMethod(serviceName = "用户删除处理")
    public int del(Integer id) {
        return managerBeanDao.del(id);
    }

    @Override
    @LogMethod(serviceName = "用户修改处理")
    public ManagerBean edit(ManagerBean managerBean) {
        managerBeanDao.edit(managerBean);
        ManagerBean result=managerBeanDao.one(managerBean.getId());
        return result;
    }

    @Override
    @LogMethod(serviceName = "用户查询处理")
    public List<ManagerBean> all(ManagerBean managerBean) {
        return managerBeanDao.all(managerBean);
    }

    @Override
    @LogMethod(serviceName = "用户查询处理")
    public ManagerBean one(Integer id) {
        return managerBeanDao.one(id);
    }

    @Override
    @LogMethod(serviceName = "用户分页处理")
    public void page(Page page, ManagerBean managerBean) {
        int count=managerBeanDao.pageCount(managerBean);//查询数据总条数
        Object data=managerBeanDao.page(page,managerBean);//查询当前页的数据
        page.setCount(count);//设置总条数
        page.setData(data);//设置当前页的数据
    }
}
